
<?php get_main_menu("admin")?>
<?php
mysql_select_db($database_drycleaners_conn, $drycleaners_conn);
$query_get_material_service_cost = "
SELECT material_service_cost.price,
       material_service_cost.express_extra_price,
       material_service_cost.id,
       service.name as service_name,
	   item.name as item_name,
       period.open_date,
	   period.year,
       period.close_date,
       material.name as material_name
  FROM    (   (   drycleaners.material_service_cost material_service_cost
               INNER JOIN
                  drycleaners.material material
               ON (material_service_cost.material_id = material.id))
           INNER JOIN
              drycleaners.service service
           ON (material_service_cost.service_id = service.id))
       INNER JOIN
          drycleaners.period period
       ON (material_service_cost.period_id = period.id)
	   
	  	LEFT OUTER JOIN
       drycleaners.item item
       ON (material_service_cost.item_id = item.id)
	   Where material_id='".$_REQUEST['material_id']."'
";
$get_material_service_cost = mysql_query($query_get_material_service_cost, $drycleaners_conn) or die(mysql_error());
$row_get_material_service_cost = mysql_fetch_assoc($get_material_service_cost);
$totalRows_get_material_service_cost = mysql_num_rows($get_material_service_cost);

$colname_get_material_service_cost_by_id = "-1";
if (isset($_GET['material_service_cost_id'])) {
  $colname_get_material_service_cost_by_id = $_GET['material_service_cost_id'];
}
mysql_select_db($database_drycleaners_conn, $drycleaners_conn);
$query_get_material_service_cost_by_id = sprintf("SELECT * FROM material_service_cost WHERE id = %s", GetSQLValueString($colname_get_material_service_cost_by_id, "int"));
$get_material_service_cost_by_id = mysql_query($query_get_material_service_cost_by_id, $drycleaners_conn) or die(mysql_error());
$row_get_material_service_cost_by_id = mysql_fetch_assoc($get_material_service_cost_by_id);
$totalRows_get_material_service_cost_by_id = mysql_num_rows($get_material_service_cost_by_id);
?>
<?php include"includes/table_settings.php"?>
              
<?php
 if($_REQUEST['material_service_cost_delete']==true && $_REQUEST['id']!=""){
 
 $query_remove_record="update material_service_cost set record_status='deactivated', deleted_by='".$loggedin_id."',  deleted_date='".date("y-m-d")."' where material_service_cost.id='".$_REQUEST["id"]."'";
 mysql_query($query_remove_record,$drycleaners_conn) or die(mysql_error());
 if(mysql_affected_rows($drycleaners_conn)>0){
	 redirect_delete("user_view","2",$_REQUEST["id"]);
	 }
 }
?>        
 <div> <a href=".?material_view"><img src="images/back-button.png" width="30" height="30" title="Back" /></a><a href=".?material_service_cost_add&action=Add&material_id=<?php echo $_REQUEST["material_id"]?>">
  <img src="images/add-button.jpg" width="30" height="30" title="Add <?php echo $object_name ?>" /></a>
              <table cellpadding="0" cellspacing="0" border="0" id="dataTable">
                <thead>
                  <tr>
                    <th>Id</th>
                    <th>Item</th>
                   	<th>Service</th>
                    <th>Period</th>
                    <th>Cost</th>
                    <th>Express Extra Cost</th>
                    <th></th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>
                  <!--Loop start, you could use a repeat region here-->
  <?php do{?>
    <!--Loop start, you could use a repeat region here-->
    <tr>
      <td><?php echo $row_get_material_service_cost['id']?></td>
      <td><?php echo $row_get_material_service_cost['item_name']?></td>
      <td><?php echo $row_get_material_service_cost['service_name']?></td>
      <td><?php echo date("d-M",strtotime($row_get_material_service_cost['open_date']))." - ".date("d-M",strtotime($row_get_material_service_cost['close_date']))." ".$row_get_material_service_cost['year']?></td>
      <td><?php echo $row_get_material_service_cost['price']?></td>
      <td><?php echo $row_get_material_service_cost['express_extra_price']?></td>
      <td align="center"><a href=".?material_service_cost= &amp;material_service_cost_edit= true&amp;id=<?php echo $row_get_material_service_cost['id']; ?>&action=Edit"><input name="" value="Edit" type="submit" id="edit_forms"/></a></td>
      <td align="center"><a href=".?material_service_cost_view&amp;material_service_cost_delete=true&id=<?php echo $row_get_material_service_cost['id']; ?>"><input name="" value="Delete" type="submit" id="delete_forms"/></a></td>
    </tr>
    <?php }while($row_get_material_service_cost=mysql_fetch_assoc($get_material_service_cost));?>
                  <!--Loop end-->
                </tbody>
              </table>
<?php
mysql_free_result($get_material_service_cost);

mysql_free_result($get_material_service_cost_by_id);
?>
</div>